#include "_old_ErrorEvent.h"

namespace mp_error
{

	ErrorEvent::ErrorEvent()
		:Event()
	{
		m_messages = 
			new string[ERROR_EVENT_DEF_SIZE];
	}

	ErrorEvent::~ErrorEvent()
	{
		delete [] m_messages;
	}

	bool ErrorEvent::IsTriggered()
	{
		return m_triggerCount > 0;
	}
	
	bool ErrorEvent::AddErrorMessage(const char* msg)
	{
		return AddErrorMessage(string(msg));
	}

	bool ErrorEvent::AddErrorMessage(const string msg)
	{
		//Set last possible error message, to state that the
		// error buffer is full.
		if ( m_triggerCount >= (m_messageBufferSize - 1))
		{
			m_messages[m_messageBufferSize - 1] = 
				"ErrorEvent Error: Error Buffer Full!";
			return false;
		}
		
		m_messages[m_triggerCount++] = msg;
		
		return true;
	}
	
	string ErrorEvent::GetErrorMessage()
	{
		string msg;
		if ( m_triggerCount <= 0 )
		{
			return msg = "ErrorEvent: No Errors!";
		}
		else
		{
			msg = m_messages[ m_triggerCount - 1 ];
			m_messages[ --m_triggerCount ] = "";
		}
		return msg;
	}

	const string ErrorEvent::PeekLastErrorMessage()
	{
		string msg;
		if ( m_triggerCount <= 0 )
		{
			return msg = "ErrorEvent: No Errors!";
		}
		else
		{
			msg = m_messages[ m_triggerCount - 1 ];
		}
		return msg;
	}
}